//
//  YBMineOpenVipPopupView.swift
//  Moonlight
//
//  Created by Penlon Kim on 2023/6/30.
//  Copyright © 2023 Moonlight Game Streaming Project. All rights reserved.
//

import UIKit
import SnapKit
import SwifterSwift

class YBMineOpenVipPopupView: UIView {
    
    var onKnow: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(bgView)
        bgView.addSubviews([imgView, titleLabel, desLabel, knowBtn])
        
        bgView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
            make.width.equalTo(kScreenWidth*0.77)
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(25)
            make.height.equalTo(25)
        }
        
        desLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(titleLabel.snp.bottom).offset(12)
            make.height.equalTo(18)
        }
        
        imgView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(desLabel.snp.bottom).offset(20)
            make.height.equalTo(bgView.snp.width).multipliedBy(0.5)
        }
        
        knowBtn.snp.makeConstraints { make in
            make.top.equalTo(imgView.snp.bottom).offset(20)
            make.centerX.equalToSuperview()
            make.size.equalTo(CGSizeMake(kScreenWidth*0.6, 44))
            make.bottom.equalTo(-25)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - lazy
    private lazy var bgView: UIView = {
        let view = UIView(color: .lightWhiteDark27)
        return view
    }()
    
    private lazy var imgView: UIImageView = {
        let iv = UIImageView(image: UIImage(named: "icon_networkerror"))
        iv.contentMode = .scaleAspectFill
        iv.clipsToBounds = true
        return iv
    }()
    
    private lazy var titleLabel = self.bk_addLabel(text: "敬请期待", font: .systemFont(ofSize: 18, weight: .medium), bgColor: .clear, textColor: .lightBlack51DarkLight230, align: .center)
    
    private lazy var desLabel = self.bk_addLabel(text: "更多权益待解锁~", font: .systemFont(ofSize: 14), bgColor: .clear, textColor: ColorDef.gray153, align: .center)
    
    private lazy var knowBtn: UIButton = {
        let btn = self.bk_addGradientButton(title: "我知道了", font: .systemFont(ofSize: 16, weight: .medium), titleColor: .white, gradientSize: CGSizeMake(kScreenWidth*0.6, 44), colors: [kRGBColor(88, 182, 255), kRGBColor(40, 128, 237)])
        btn.bk_addStyleWith(cornerRadius: 22, corners: .allCorners)
        btn.bk_addTarget { [unowned self] sender in
            self.onKnow?()
        }
        return btn
    }()
    
}
